package com.sunriz.controller;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @Author: weizs
 * @Create: 2023/11/21 14:14
 * @Description:
 */
public class test {
    static final String JDBC_URL = "jdbc:mysql://47.98.177.147:3306/nms_test";
    static final String USER = "root";
    static final String PASSWORD = "Su123456!";

    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();
        try (Connection connection = DriverManager.getConnection(JDBC_URL, USER, PASSWORD)) {
            Statement statement = connection.createStatement();
            for (int i = 2; i <= 84; i++) {
                for (int j = 1; j <= 20; j++) {
                    for (int x = 1; x <= 8; x++) {
                        String sql1 = "INSERT INTO device_relation(td_code,item_code,parent_item_code) VALUES ('hc', '192.168.2."+i+"_"+j+"_"+x+"', '192.168.2."+i+"_"+j+"');";
                        statement.addBatch(sql1);
                        System.out.println(sql1);
                    }
////                    System.out.println(i);
                }
            }
            statement.executeBatch();
            long endTime = System.currentTimeMillis();
            long totalTime = endTime - startTime;
            System.out.println("耗时："+totalTime+"毫秒");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
